import matplotlib.pyplot as plt
import numpy as np

if __name__ == '__main__':
    x = np.linspace(-5, 5, 101)
    # print(x)
    y = np.linspace(-5, 5, 101)
    # print(y)

    X, Y = np.meshgrid(x, y)

    Z1 = 3 - X - Y
    Z2 = X + 2 * Y -4

    # 单位：英寸
    figure = plt.figure(figsize=(10, 7))
    axes = figure.add_subplot(111, projection='3d')

    # 通过 xyz 点绘制曲面
    axes.plot_surface(X, Y, Z1, color='blue', alpha=0.5)
    axes.plot_surface(X, Y, Z2, color='red', alpha=0.5)

    # 设置标签
    axes.set_xlabel("X-axis", fontsize=12)
    axes.set_ylabel("Y-axis", fontsize=12)
    axes.set_zlabel("Z-axis", fontsize=12)

    # 设置xyz 轴的坐标范围
    axes.set_xlim([-5, 5])
    axes.set_ylim([-5, 5])
    axes.set_zlim([-19, 11])

    # 关闭坐标平面底色
    axes.xaxis.pane.fill = False
    axes.yaxis.pane.fill = False
    axes.zaxis.pane.fill = False

    # 设置图题
    # axes.set_title('x+2y+3z=0 surface')

    axes.view_init(elev=20, azim=30)

    plt.show()
